package pricingTag;

/*
 *  what function should be implemented in store object?

 */
public class Product {
	int ID;
	String name;
	int storage; // storage of this product, is it useful?
	private double purchase_cost; // the cost of input this product.
	double price; // current price.
	double inventory_cost; // inventory cost per day
	int input_date;
	double price_sensitivity;// how many customers will stop buying this p
	Global global;
	double benefit;// benefit of selling one product
	int numSelling; // expected number of selling of this product in next month
	Store selling_store;

	int get_selling_change(double price_change) {
		int selling_change = 0;
		selling_change = (int) ((int) price_change * price_sensitivity);
		return selling_change;
	}

	public Product(String name, double price, double purchase_cost,
			int numSelling, Store selling_store) {
		// TODO Auto-generated constructor stub
		this.name = name;
		this.price = price;
		// this.global = global;
		this.selling_store = selling_store;
		this.numSelling = numSelling;
		this.purchase_cost = purchase_cost;

		ProductRecord pr = selling_store.global.find_product_record(name);
		if (pr == null) {
			// selling_store.global.product_names.add(this.name);
			selling_store.global.product_records.add(new ProductRecord(this));
//			System.out.println(this + " is added");
		} else {
			// System.out.println("ADD");
			pr.add_record(this);
		}
		this.compute_benefit();

	}

	void change_price(double new_price) {
		this.price = new_price;
		this.compute_benefit();
	}

	void change_purchase_cost(double pc) {
		this.purchase_cost = pc;
		this.compute_benefit();
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "Product name: " + this.name;
	}

	void show() {

	}

	double compute_benefit() {
		this.benefit = this.price - this.purchase_cost;
		return benefit;
	}

	// public static void main(String[] args) {
	// Product p = new Product();
	// p.show();
	//
	// }

}
